
#include "mlColor32.h"

namespace ml
{

	Color32::Color32()
	{
		R = G = B = A = 0;
	}

	Color32::Color32(unsigned char r, unsigned char g,
				 unsigned char b, unsigned char a)
	{
		R = r;
		G = g;
		B = b;
		A = a;
	}

	Color32::Color32(const Color32 &a)
	{
		R = a.R;
		G = a.G;
		B = a.B;
		A = a.A;
	}

	Color32::~Color32()
	{
	}

	Color32 &Color32::operator =(const Color32 &a)
	{
		R = a.R;
		G = a.G;
		B = a.B;
		A = a.A;
		return *this;
	}

	bool Color32::operator ==(const Color32 &a) const
	{
		return (R == a.R) && (G == a.G) && (B == a.B) && (A == a.A);
	}

	bool Color32::operator !=(const Color32 &a) const
	{
		return (R != a.R) || (G != a.G) || (B != a.B) || (A != a.A);
	}

	Color32 Color32::operator -(void) const
	{
		return Color32(255 - R, 255 - G, 255 - B, 255 - A);
	}

	Color32 Color32::operator +(const Color32 &a) const
	{
		return Color32(R + a.R, G + a.G, B + a.B, A + a.A);
	}

	Color32 Color32::operator -(const Color32 &a) const
	{
		return Color32(R - a.R, G - a.G, B - a.B, A - a.A);
	}

	Color32 Color32::operator *(const Color32 &a) const
	{
		return Color32(R * a.R, G * a.G, B * a.B, A * a.A);
	}

	Color32 Color32::operator *(const unsigned int a) const
	{
		return Color32(R * a, B * a, G * a, A * a);
	}

	Color32 Color32::operator /(const unsigned int a) const
	{
		return Color32(R / a, G / a, B / a, A / a);
	}

	Color32 Color32::operator /(const Color32 &a) const
	{
		return Color32(R / a.R, G / a.G, B / a.B, A / a.A);
	}

	Color32 &Color32::operator +=(const Color32 &a)
	{
		*this = *this + a;
		return *this;
	}

	Color32 &Color32::operator -=(const Color32 &a)
	{
		*this = *this - a;
		return *this;
	}

	void Color32::set(unsigned char r, unsigned char g,
				 unsigned char b, unsigned char a)
	{
		R = r;
		G = g;
		B = b;
		A = a;
	}

	unsigned int Color32::getUnsignedInt(void)
	{
		return 0;//(unsigned int)(((int)R << 24) | ((int)G << 16) | ((int)B << 8) | ((int)A));
	}

	ml::Vec4 Color32::toVec4(void)
	{
		float a = 1 / 255.0f;
		return ml::Vec4(R * a, G * a, B * a, A * a); 
	}

}